package org.systm.adminuser.controller;

import org.global.basic.BasicController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.systm.adminuser.entity.UserRole;
import org.systm.adminuser.params.ExhibitRole;
import org.systm.adminuser.params.UserRoleParams;
import org.systm.adminuser.service.UserRoleService;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/role")
public class UserRoleController extends BasicController<String, UserRole, UserRoleParams<String>, UserRoleService> {
    @Resource
    UserRoleService userRoleService;

    @Override
    public UserRoleService service() {
        return this.userRoleService;
    }

    @Override
    public Object allAfter(List<UserRole> all) throws NoSuchMethodException {
        List<ExhibitRole> exhibitRoles = userRoleService.levelTree(all, ExhibitRole.class);
        userRoleService.treeSort(exhibitRoles);
        return exhibitRoles;
    }

    @Override
    public Object pageAfter(List<UserRole> page) throws NoSuchMethodException {
        List<ExhibitRole> exhibitRoles = userRoleService.levelTree(page, ExhibitRole.class);
        userRoleService.treeSort(exhibitRoles);
        return exhibitRoles;
    }
}
